<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('划分设备')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-device-edit">

        <input name="id" th:value="${id}" type="hidden">

        <!--<div class="form-group">-->
        <!--<label class="col-sm-3 control-label is-required">选择合作商：</label>-->
        <!--<div class="col-sm-8">-->
        <!--<div class="input-group">-->
        <!--<input id="partnerId" name="partnerId" type="hidden"/>-->
        <!--<input class="form-control" id="treeName" type="text" onclick="selectPartnerTree()"-->
        <!--readonly="true" required>-->
        <!--<span class="input-group-addon"><i class="fa fa-search"></i></span>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">选择合作商：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="treeId" name="partnerId" type="hidden" th:value="${partner?.id}"/>
                    <input class="form-control" type="text" onclick="selectPartnerTree()" id="treeName" readonly="true"
                           th:value="${partner?.fullName}" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>


        <!--<div class="form-group">-->
        <!--<label class="col-sm-3 control-label is-required">是否活动设备：</label>-->
        <!--<div class="col-sm-8">-->
        <!--<div class="radio-box" th:each="dict : ${@dict.getType('sys_device_is_activity')}">-->
        <!--<input type="radio" th:id="${'isActivity_' + dict.dictCode}" name="isActivity"-->
        <!--th:value="${dict.dictValue}" th:checked="${dict.default}" required>-->
        <!--<label th:for="${'isActivity_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->

        <!--选择活动-->
        <div class="form-group">
            <label class="col-sm-3 control-label">选择活动：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="eventId" name="eventId" type="hidden"/>
                    <input class="form-control" type="text" onclick="selectRadioEvent()" id="eventName"
                           readonly="true">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="remarks" class="form-control"></textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/device";
    $("#form-device-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/allotDevOne", $('#form-device-edit').serialize());
        }
    }

    /*选择合作商*/
    function selectPartnerTree() {
        // var prefix = ctx + "system/partner";
        // $.modal.open("选择顶级合作商", prefix + "/headPartners");
        var prefix = ctx + "system/partner";
        var options = {
            title: '选择合作商',
            width: "380",
            url: prefix + "/selectPartnerTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        layer.close(index);
    }


    // 选择活动
    function selectRadioEvent() {
        var prefix = ctx + "system/event";
        $.modal.open("选择活动", prefix + "/choiceEvents");
    }


</script>
</body>
</html>